﻿#pragma once
#include <string>
#include <deque>
#include <bitset>
#include <variant>
#include <cstdint>

enum protocolType
{
	GINT,
	GSTR,
	GSIZE
};

class _Option
{
public:
	protocolType _type;
	int _length = 0;
	std::string _description;
};

using OptionValue = std::variant<int64_t, std::string>;

class ProtocolOption
{
	friend class ProtocolConverter;
	friend class ProtocolBuilder;

public:
	ProtocolOption();
	// 获取单次发送的最大长度
    int64_t maxSize();
	// 添加，
	// 占用的字节长度，信息类型，描述
    bool append(int64_t length, protocolType type, std::string description = "");

private:
	// 控制信息
	std::bitset<1> _control;

	std::deque<_Option> _optionList;
	// 表明指定消息长度的下标
    int64_t _size_index;
	// 表明单个消息的最大长度:由SIZE字段的位数控制
    int64_t _maxSize;
};
